home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / grafik / cbgi111 / src / dt2851 / dt2851.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-17  |  6.9 KB  |  219 lines

  1. /**************************** ATI.H *************************************/
  2. /*    Data Translation DT2851 driver header file.  Contains driver    */
  3. /*  specific macros and structures.                    */
  4. /************************************************************************/
  5.  
  6. #include <dos.h>        /* Outport etc.                */
  7.  
  8. #define OFF    0        /* Switch settings.            */
  9. #define ON    1
  10.  
  11. #define FEEDBACK    0    /* Operating modes for the card.    */
  12. #define LOAD_LUT     4
  13. #define SLOW_SCAN    5
  14. #define PORT_OUT        6
  15. #define PORT_IN         7
  16.  
  17. #define INCSR1    (base)        /* Registers to control the board.    */
  18. #define INCSR2    (base+2)
  19. #define OUTCSR    (base + 4)
  20. #define CURSOR    (base + 6)
  21. #define INDEX    (base + 8)
  22. #define INPUT_LUT_VALUE        (base + 0xA)
  23. #define OUTPUT_LUT_REDGRN_VALUE    (base + 0xC)
  24. #define OUTPUT_LUT_BLUE_VALUE    (base + 0xE)
  25.  
  26.                 /* Set bit on a specific port.        */
  27. #define SET_BIT( port, mask, state) \
  28.             (outport( (port), ((inport((port)) & mask) \
  29.                                   | ((state) ? ~mask : 0))))
  30.  
  31.                 /* Control the display.            */
  32. #define DISPLAY( state)          SET_BIT( OUTCSR, 0xff7f, (state))
  33.  
  34.                 /* Sync generated externally?        */
  35. #define EXT_TIME( state)      SET_BIT( OUTCSR, 0xffdf, (state))
  36.  
  37.                 /* Turn on boards overwhite cursor?    */
  38. #define SET_CURSOR(state)         SET_BIT( OUTCSR1, 0xffbf,(state))
  39.  
  40.                 /* Generate interrrupt when done     */
  41.                 /*   operation?                */
  42. #define INTERRUPT_ON_DONE( state) SET_BIT( INCSR1, 0xffbf, (state))
  43.  
  44.                 /* Stop operation.            */
  45. #define ENSTOP( state)          SET_BIT( INCSR1, 0xfff7, (state))
  46.  
  47.                 /* Start operation.            */
  48. #define BUSY( state)          SET_BIT( INCSR1, 0xff7f, (state))
  49.  
  50.                 /* What input Look-Up Table is being     */
  51.                 /*   used?                */
  52. #define INPUT_LUT( index)      outport( INCSR1, (inport( INCSR1) \
  53.                                               & 0xfff8) | ((index)&0x7))
  54.  
  55.                 /* What output Look-Up Table is being     */
  56.                 /*   used?                */
  57. #define OUTPUT_LUT( index)      outport( OUTCSR, (inport( OUTCSR) \
  58.                                               & 0xfff8) | ((index)&0x7))
  59.  
  60.                 /* What entry is visible?        */
  61. #define LUT_ENTRY( index)      (outport( INDEX, (index)))
  62.  
  63.                 /* Set entry for input LUT.        */
  64. #define INPUT_LUT_ENTRY( index, value) ( LUT_ENTRY( (index)), \
  65.                     outport( INPUT_LUT_VALUE, (value)))
  66.  
  67.                 /* Set entry for red output LUT.    */
  68. #define OUTPUT_LUT_RED_ENTRY( index, value) ( LUT_ENTRY( (index)), \
  69.                   outport( OUTPUT_LUT_REDGRN_VALUE, \
  70.                   (inport( OUTPUT_LUT_REDGRN_VALUE) \
  71.                   & 0xff00) | (value)))
  72.  
  73.                 /* Set entry for green output LUT.    */
  74. #define OUTPUT_LUT_GREEN_ENTRY( index, value) ( LUT_ENTRY( (index)), \
  75.                   outport( OUTPUT_LUT_REDGRN_VALUE, \
  76.                   (inport( OUTPUT_LUT_REDGRN_VALUE) \
  77.                   & 0x00ff) | ((value) << 8)))
  78.  
  79.                 /* Set entry for blue output LUT.    */
  80. #define OUTPUT_LUT_BLUE_ENTRY( index, value) ( LUT_ENTRY( (index)), \
  81.                   outport( OUTPUT_LUT_BLUE_VALUE, (value)))
  82.  
  83.                 /* Read entry for red output LUT.    */
  84. #define INPUT_LUT_RED_ENTRY( index) ( LUT_ENTRY( (index)), \
  85.                   inport( OUTPUT_LUT_REDGRN_VALUE) \
  86.                   & 0x00ff)
  87.  
  88.                 /* Read entry for green output LUT.    */
  89. #define INPUT_LUT_GREEN_ENTRY( index) ( LUT_ENTRY( (index)), \
  90.                   ((inport( OUTPUT_LUT_REDGRN_VALUE) \
  91.                   & 0xff00) >> 8))
  92.  
  93.                 /* Read entry for blue output LUT.    */
  94. #define INPUT_LUT_BLUE_ENTRY( index) ( LUT_ENTRY( (index)), \
  95.                   inport( OUTPUT_LUT_BLUE_VALUE))
  96.  
  97.                       /* Set the card's operating mode.    */
  98. #define MODE( value)    outport( INCSR2, \
  99.             (inport( INCSR2) & 0xff8f) | ((value & 0x7) << 4))
  100.  
  101.                 /* Set the page digitised input goes to.*/
  102. #define INPUT_PAGE( page)      SET_BIT( INCSR2, 0xff7f, (page))
  103.  
  104.                 /* Write protect bits on the card.    */
  105. #define WRITE_PROTECT( value)      outport( INCSR2, \
  106.                  (inport( INCSR2) & 0xfff0) | (value & 0xf))
  107.  
  108.                      /* Display this page.            */
  109. #define DISPLAY_PAGE( page)      SET_BIT( OUTCSR, 0xffef, (page))
  110.  
  111.                 /* Go! Go! Go!                */
  112. #define PERFORM_OPERATION()      ENSTOP( ON)
  113.  
  114.  
  115. extern int  base;            /* Base port for the card.    */
  116. extern unsigned char line_buffer[ 512];    /* Buffer in real mode memory.    */
  117. extern int  graphics_mode;        /* Flag special drawing mode.    */
  118. extern unsigned int current_row;    /* Row, column.            */
  119. extern unsigned int current_column;
  120. extern unsigned long page_offset;    /* Basically drawing page.    */
  121.  
  122.  
  123. typedef struct {
  124.   unsigned char length;            /* # of color entries in palette*/
  125.   unsigned char colora[256*3];        /* Up to 256 color entries    */
  126.   } NN9PALETTE;
  127.  
  128. #define MAX_MODES     1    /* The maximum number of modes.        */
  129. #define MAX_COLOURS     256    /* The maximum number of colours.    */
  130.  
  131.                 /* Copy real memory row to the card.    */
  132. #define ROW_UPDATE()    {\
  133.             copy_to_extended( 0xA00000L + 512L*current_row + \
  134.                       page_offset, line_buffer, 256);\
  135.             }
  136.  
  137.                 /* Copy row from the card to real     */
  138.                 /*  memory.                */
  139. #define GET_ROW()    {\
  140.             copy_from_extended( line_buffer, 0xA00000L + \
  141.                         512L*current_row + page_offset,\
  142.                         256);\
  143.             }
  144.                 /* A macro to calculate the current    */
  145.                 /*  address from (x,y) position info.    */
  146. #define CALC_ADDR( x, y)   {\
  147.                if( y != current_row)\
  148.                    {\
  149.                    if( graphics_mode)\
  150.                        { ROW_UPDATE();}\
  151.                    current_row = y;\
  152.                    GET_ROW();\
  153.                    }\
  154.                current_column = x;\
  155.                }
  156.  
  157.  
  158.                     /* A macro to change the current address*/
  159.                 /*  by 1 in the x direction.        */
  160. #define X_INCREMENT_CALC() { current_column++; }
  161.  
  162.                     /* A macro to change the current address*/
  163.                 /*  by 1 in the y direction.        */
  164. #define Y_INCREMENT_CALC() { \
  165.                current_row++;\
  166.                GET_ROW();\
  167.                }
  168.  
  169.                     /* A macro to change the current address*/
  170.                 /*  by -1 in the y direction.        */
  171. #define Y_DECREMENT_CALC() { \
  172.                current_row--;\
  173.                GET_ROW();\
  174.                }
  175.  
  176.                       /* A macro to put a pixel of colour     */
  177.                 /*  colour on the screen at the current    */
  178.                 /*  address.                */
  179. #define POINT( colour)    { \
  180.             line_buffer[current_column] = colour;\
  181.             if( !graphics_mode)\
  182.                 { ROW_UPDATE();}\
  183.             }
  184.  
  185.                       /* A macro to xor a pixel of colour     */
  186.                 /*  colour on the screen at the current    */
  187.                 /*  address.                */
  188. #define XOR_POINT( colour) { \
  189.                line_buffer[current_column] ^= colour;\
  190.                if( !graphics_mode)\
  191.                     { ROW_UPDATE();}\
  192.                }
  193.                       /* A macro to read a pixel from the        */
  194.                 /*  screen at the current address.    */
  195. #define RD_POINT()    ( line_buffer[current_column])
  196.  
  197. /* Combinations of the address calculation macros with the draw pixel    */
  198. /*  macro using the current colour.                    */
  199.  
  200. #define DRAW_POINT( x, y)   { CALC_ADDR( (x), (y));\
  201.                   POINT( current_colour);\
  202.                     }
  203.  
  204. #define X_INCREMENT_POINT() { X_INCREMENT_CALC();\
  205.                   POINT( current_colour);\
  206.                     }
  207.  
  208. #define Y_INCREMENT_POINT() { Y_INCREMENT_CALC();\
  209.                   POINT( current_colour);\
  210.                     }
  211.  
  212. #define Y_DECREMENT_POINT() { Y_DECREMENT_CALC();\
  213.                   POINT( current_colour);\
  214.                     }
  215.  
  216.  
  217.  
  218.  
  219.